package com.wjk.cms.common;


import org.apache.commons.lang3.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class AppType {

    public static final String APP = "app";

    public static final String WX_GZH = "wx_gzh";

    public static final String WX_XCX = "wx_xcx";

    public static String get(String defaultValue) {
        String appType = get();
        return StringUtils.isEmpty(appType) ? defaultValue : appType;
    }

    public static String get() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        if (request == null) {
            return null;
        }
        return request.getHeader("app_type");
    }

}
